package com.zy.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * java python lua js
 *
 * @author : hanhuafeng
 * @date : 2023/11/13 17:29
 */
@Getter
public enum ScriptLanguageEnum {
    /**
     * java
     */
    JAVA("java"),
    /**
     * python
     */
    PYTHON("python"),
    /**
     * lua
     */
    LUA("lua"),
    /**
     * js
     */
    JS("js");

    @EnumValue
    @JsonValue
    private final String language;

    ScriptLanguageEnum(String language) {
        this.language = language;
    }

    @JsonCreator
    public static ScriptLanguageEnum getEnum(String language) {
        for (ScriptLanguageEnum scriptLanguageEnum : ScriptLanguageEnum.values()) {
            if (scriptLanguageEnum.getLanguage().equals(language)) {
                return scriptLanguageEnum;
            }
        }
        return null;
    }
}
